/*
 * @Author: HeAo
 * @Date: 2021-09-29 11:03:59
 * @LastEditTime: 2021-09-29 11:12:33
 * @LastEditors: HeAo
 * @Description:
 * @FilePath: \web2103-2105\web2103code\3-1-ES6\day05\5-generator.js
 * 别乱动！
 */

// 声明一个generator函数
function* myGenFun () {
  console.log('状态一');
  let result = yield 'hello'

  console.log('状态二');
  console.log(result);
  yield 'world'

  console.log('状态三');
  return 'ending'  // retrun标志着该函数的结束
}
// generator函数的执行结果，是一个迭代器对象
let result = myGenFun()
console.log(result);
console.log(result.next());
console.log(result.next('你好'));
console.log(result.next());
